<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>{$Think.config.site.title} - 用户管理</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">

    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      
      <div class="row">
          <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>修改商户信息</h5>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal" action="" enctype="multipart/form-data" id="myformdata">
                        <input type="hidden" name="id" value="{$v.id}" />
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商铺名称</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control " name="name" id="name"  value="{$v.name}" required="" aria-required="true" placeholder="输入商铺名称">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="phone" di="phone" value="{$v.phone}" required="" aria-required="true" placeholder="输入电话号码">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商铺图片</label>
                                <div class="col-sm-10">
                                    <input type="file" class="" name="picture" id="picture" value="" placeholder="上传图片">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" >所在区域</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="area" name="area" value="{$v.area}" placeholder="输入所在区域">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">详细地址</label>
                                <div class="col-sm-10">
                                   <input type="text" class="form-control" id="addr" name="addr" value="{$v.addr}" placeholder="输入详细地址">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                               <label class="col-sm-2 ">经度</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="longitude" name="longitude" value="{$v.longitude}" placeholder="输入经度">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">纬度</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control"  id="latitude" name="latitude" value="{$v.latitude}" placeholder="输入纬度">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">营业时间</label>
                                <?php
                                    if(strlen($v['shopstart'])==1){
                                        $start =  '0'.$v['shopstart'].':00';
                                    }else if(strlen($v['shopstart'])==2){
                                        $start =  $v['shopstart'].':00';        
                                    }else if(strlen($v['shopstart'])==3){
                                        $start =  '0'.$v['shopstart'];
                                        $start=insertToStr($start, 2, ":");
                                    }else if(strlen($v['shopstart'])==4){
                                        $start =  $v['shopstart'];
                                        $start=insertToStr($start, 2, ":");
                                    }

                                    if(strlen($v['shopend'])==1){
                                        $end =  '0'.$v['shopend'].':00';
                                    }else if(strlen($v['shopend'])==2){
                                        $end =  $v['shopend'].':00';        
                                    }else if(strlen($v['shopend'])==3){
                                        $end =  '0'.$v['shopend'];
                                        $end=insertToStr($end, 2, ":");
                                    }
                                    else if(strlen($v['shopend'])==4){
                                        $end =  $v['shopend'];
                                        $end=insertToStr($end, 2, ":");
                                    }

                                ?>
                                <div class="col-sm-10">
                                    <input type="time" class="form-control layer-date" required="" aria-required="true" style="width:110px; display: inline-block;" name="shopstart" value="{$start}" placeholder="输入开始时间"><span class=""> ~ </span><input type="time" style="width:110px;display: inline-block;" class="form-control layer-date" name="shopend" required="" aria-required="true" value="{$end}" placeholder="输入结束时间">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">人均消费</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="averageprice" id="averageprice"  value="{$v.averageprice}" placeholder="输入人均消费">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">佣金比例</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control"  id="brokerage" name="brokerage" value="{$v.brokerage}" placeholder="输入佣金比例">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-5 col-sm-offset-5">
     
                                    　　　<input type="button" class="btn btn-primary" value="提 交" id="onbtn">
                           
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>      
        </div>
    </div>

    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/content.min.js?v=1.0.0"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/jquery.validate.min.js"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/validate/messages_zh.min.js"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
</body>

</html>
<script>
$(document).ready(function(){
    $('#onbtn').click(function(){
        var name = $('#name').val();
        var phone = $('#phone').val();
        var area = $('#area').val();
        if(name==''){
            $('#name').focus();
            return false;
        }
        if(phone==''){
            $('#phone').focus();
            return false;
        }
        if(area==''){
            $('#area').focus();
            return false;
        }

        //var fomrData = $("#myformdata").serialize();
        var formData = new FormData($( "#myformdata" )[0]);
        var action = 'edit';
        $.ajax({
            type : 'POST',
            url : '<?php echo \think\Request::instance()->root(); ?>/ausagent/Seller/'+action,
            data: formData, 
            async: false, 
            cache: false, 
            contentType: false, 
            processData: false, 
            success : function(result) {
                //layer.close(layer1);
                if(0 === result.code) {
                    layer.msg(result.msg, {icon: 1});
                    parent.location.reload();
                }  else  {
                    //删除失败
                    layer.msg(result.msg, {icon: 5});
                }
            },
            error : function(){
                res = false;
                layer.msg('服务器错误！请稍后重试', {icon: 2});
            }
        })
    });
})
</script>